#include  <cstdio>
#include  <iostream>
using namespace std;

int main(int argc, char *argv[])
{
	int n;
	char ss[30];
	scanf("%d",&n);
	while( n!=0 )
	{
		int sum = 0, min = 25;
		for( int i = 0; i < n ; ++i )
		{
			int total = 0;
			for( int j = 0; j < 25 ; ++j )
			{
				ss[j] = getchar();
				if(ss[j] == ' ')
					total++;
			}
			getchar();
			sum += total;
			min = total < min ? total : min;
			
		}
		
		sum -= (min * n);
		printf("%d\n",sum);
		scanf("%d",&n);
	}
}
